package sg.edu.nus.iss.phoenix.schedule.dao.impl;

import java.sql.Time;
import java.util.Calendar;
import java.util.Date;

import sg.edu.nus.iss.phoenix.utils.CommonUtils;

/**
 * @author Vipul Sanghrajka
 *
 */
public class Utility {
	
	public static final int CREATE_SCHEDULE = 1;
	public static final int COPY_SCHEDULE = 2;
	public static final int DELETE_SCHEDULE = 3;
	public static final int MODIFY_SCHEDULE = 4;
	public static int WEEK_OF_YEAR=Calendar.getInstance().get(Calendar.WEEK_OF_YEAR);
	public static java.util.Date now = new java.util.Date();
	
	/**
	 * Utility method to get first day of a week.
	 * @param week
	 *            The week of the year.
	 * @param day
	 *            The day of the week.
	 * @param year
	 *            The year of the date.
	 * @return
	 *            The first {@link Date} of the week.
	 */
	public static java.sql.Date getDateforWeekDayYear(int week, int day, int year){
		Calendar calendar = Calendar.getInstance();
		calendar.clear();
		calendar.set(Calendar.WEEK_OF_YEAR, week);
		calendar.set(Calendar.YEAR, year);
		calendar.set(Calendar.DAY_OF_WEEK, day);
		// Now get the first day of week.
		Date date = calendar.getTime();
		System.out.println(date);
		return CommonUtils.changeToSQLDate(date);
		//return (java.sql.Date) date;
	}
	
	/**
	 * Utility method to get time of day.
	 * @param hh
	 *            The hour of the day.
	 * @param mm
	 *            The minute in an hour.
	 * @return
	 *            The {@link Time} of day.
	 */
	public static java.sql.Time getTimeOfDay(int hh, int mm){
	Calendar calendar = Calendar.getInstance();
	calendar = Calendar.getInstance();
	
	calendar.set(Calendar.HOUR_OF_DAY, hh);
	calendar.set(Calendar.MINUTE, mm);
	calendar.set(Calendar.SECOND, 0);
	//calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
	java.sql.Time time = new Time(calendar.getTime().getTime());
	System.out.println(time);
	return time;
	}
}
